﻿using Xejen.Communication.Configuration;
using Xejen.Communication.Endpoints;
using Xejen.Communication.Logger;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;

namespace Xejen.Communication
{
    /// <summary>
    /// 表示通讯器，抽象了向客户发起请求的通讯接口
    /// </summary>
    /// <typeparam name="TCommunicationConfig"><inheritdoc cref="CommunicationConfig{THeartbeatConfig}" path="/summary"/></typeparam>
    /// <typeparam name="THeartbeatConfig"><inheritdoc cref="HeartbeatConfig" path="/summary"/></typeparam>
    /// <creator>marc</creator>
    public interface ICommunicator<TCommunicationConfig, THeartbeatConfig>
        where TCommunicationConfig : CommunicationConfig<THeartbeatConfig>, new()
        where THeartbeatConfig : HeartbeatConfig, new()
    {
        /// <inheritdoc cref="CommunicationConfig{THeartbeatConfig}"/>
        TCommunicationConfig Config { get; set; }

        /// <inheritdoc cref="IHeartbeat{THeartbeatConfig}" path="/summary"/>
        IHeartbeat<THeartbeatConfig> Heartbeat { get; }

        /// <summary>
        /// 设置通讯配置
        /// </summary>
        /// <param name="config"><inheritdoc cref="ICommunicator{TCommunicationConfig, THeartbeatConfig}" path="/typeparam[@name='TConfig']"/></param>
        void SetConfig(TCommunicationConfig config);

        /// <summary>
        /// 注册数据库日志的记录器
        /// </summary>
        /// <param name="databaseLogger"><inheritdoc cref="IDatabaseLogger" path="/summary"/></param>
        void RegisterDatabaseLogger(IDatabaseLogger databaseLogger);
    }
}
